package com.situ.mall.controller.front;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.situ.mall.pojo.entity.Cart;
import com.situ.mall.pojo.entity.User;
import com.situ.mall.service.ICartService;
import com.situ.mall.util.JSONResult;

@Controller
@RequestMapping("/cart")
public class FrontCartController {
	@Autowired
	private ICartService cartService;

	@ResponseBody
	@RequestMapping("/insert.shtml")
	public JSONResult insert(Cart cart, HttpSession session) {
		User user = (User) session.getAttribute("user");
		cart.setUserId(user.getId());
		cartService.insert(cart);
		return JSONResult.ok("加入购物车成功");
	}
	
	@RequestMapping("/getCartListPage.shtml")
	public String getCartListPage() {
		
		return "/front/cart_list";
	}
}
